(function($) {
    $(function(event) {
		
		if ($('#children').val() > 0 || $('#babies').val() > 0  || $('#rooms').val() > 1 || $('#price-from').val() != '' || $('#price-to').val() != '' || $('#nutrition-type').val() != '' || $('#input-hotelname').val() != '' || $('#chk-onlyavail').attr('checked') == true) {
			$('.search_controls a.more').hide();
			$('.search_controls a.less').css('display', 'block');
			$('.hotel_search_more').show();
		}
		
		$('#frm-hotel-search').submit(function() {
			var arrName = [], arrVal = [];
			$this = $(this);
			$('#frm-hotel-search input[type="text"], #frm-hotel-search input[type="hidden"]').each(function() {
				if ($(this).attr('name') != undefined && $(this).val() != undefined) {
					arrName.push($(this).attr('name'));
					arrVal.push($(this).val());
				}
			});
			$('#frm-hotel-search input[type="checkbox"]').each(function() {
				if ($(this).attr('checked') == true) {
					arrName.push($(this).attr('name'));
					arrVal.push($(this).val());
				}
			});
			var u = '';
			for (var i = 0; i < arrName.length; i++) {
				u += '&' + arrName[i] + '=' + arrVal[i];
			}
			setTimeout(function() {searchWaitRedirect($this.attr('action'), u);}, tm.Config.searchResultsTimeout);
		});
		
		function searchWaitRedirect(e, u) {
			var domain = e + '?' + u;
			location.href = domain;
		}
				
    });
})(jQuery);